{% extends "team/base.html" %}

{% block container_outer %}
<div id="container" class="container-fluid">

	<div class="row">
		<div class="col-md-12">
			<div style="margin: 0 auto; max-width: 400px;">

				<ol class="breadcrumb">
					<li><a href="/team/list">用户组列表</a></li>
					<li class="active">修改用户组</li>
				</ol>

				<div class="panel panel-default">
					<div class="panel-heading">
						<h3 class="panel-title">Edit Team: {{team.name}}</h3>
					</div>
					<div class="panel-body">
						<div class="form-group">
							<label for="resume">简介（方便以后能想起这个组的作用，选填）：</label> <input
							type="text" id="resume" class="form-control" value="{{team.resume}}"/>
						</div>
						<div class="form-group">
							<label for="users">成员：</label> <input
							type="text" id="users" class="form-control" value="{{team_user_ids}}"/>
						</div>
						<button type="button" class="btn btn-default" onclick="edit_team('{{team.id}}');">
							<span class="glyphicon glyphicon-floppy-disk"></span>
							更新
						</button>
						<a href="/team/list" class="btn btn-default">
							<span class="glyphicon glyphicon-arrow-left"></span>
							返回
						</a>
					</div>
				</div>

			</div>
		</div>
	</div>

</div>
{%endblock%}


{% block more_js%}

{{super()}}
<script type="text/javascript">
$(function() {
	$("#users").select2({
        placeholder: "输入要添加组员的name",
        allowClear: true,
        multiple: true,
        quietMillis: 100,
        minimumInputLength: 1,
        id: function(obj){return obj.id;},
        initSelection: function(element, callback) {
            $.getJSON("/team/{{team.id}}/users", function(json) {
        		callback(json.users);
        	});
        },
        ajax: {
            url: "/user/query",
            dataType: 'json',
            data: function(term, page) {
                return {
                    query: term,
                    limit: 20
                };
            },
            results: function(json, page) {
                return {results: json.users};
            }
        },
        formatResult: function(obj) {return obj.name + "["+obj.cnname+"]" + "["+obj.email+"]"},
        formatSelection: function(obj) {return obj.name},
    });
});
</script>
{%endblock%}
